#ifndef Joystick_H
#define Joystick_H
#include "cocos2d.h"
using namespace cocos2d;

class Joystick :public CCLayer {
public:
	Joystick();

	void setActive(bool active);
	CCPoint getDirection();
	float getVelocity();
	void  updatePos(float dt);

	static Joystick*  create(CCPoint aPoint ,float aRadius ,CCSprite* aJsSprite,CCSprite* aJsBg);
	Joystick * init(CCPoint aPoint ,float aRadius ,CCSprite* aJsSprite,CCSprite* aJsBg);

	virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);
	virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

private:
	CCPoint mCenterPoint;
	CCPoint mCurrentPoint;
	bool	mActive;
	float	mRadius;
	CCSprite *mJsSprite;
};
#endif
